package com.caiheng.api.service.setmeal.impl;

import cn.hutool.core.util.StrUtil;
import com.caiheng.api.dao.setmeal.SetMealMapper;
import com.caiheng.api.entity.setmeal.SetMeal;
import com.caiheng.api.service.base.impl.BaseServiceImpl;
import com.caiheng.api.service.setmeal.SetMealService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 套餐列Service业务层处理
 *
 * @author ruoyi
 * @date 2022-06-06
 */
@Service
public class SetMealServiceImpl extends BaseServiceImpl<SetMealMapper, SetMeal> implements SetMealService {

    @Resource
    private SetMealMapper setMealMapper;

    @Value("${web.imgPrefix}")
    private String imgPrefix;//图片地址


    @Override
    public SetMeal getMealInfoByMealNo(String mealNo) {
        SetMeal setMeal = setMealMapper.selectOneByColumn("meal_no",mealNo);
        if(setMeal!=null){
            if(StrUtil.isNotEmpty(setMeal.getQrCode())){
                setMeal.setQrCode(imgPrefix + setMeal.getQrCode());
            }
            if(StrUtil.isNotEmpty(setMeal.getPlayBillImg())){
                setMeal.setPlayBillImg(imgPrefix + setMeal.getPlayBillImg());
            }
        }
        return setMeal;
    }
}
